<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
        <?php
        include "includes/ketnoi.php";
        include "includes/header.php";
        ?>
        <style type="text/css">
            .example{
                margin: 20px;
            }
            
        </style>
    </head>
    <body>
        <?php
        // put your code here
        include "includes/narbar.php";
        ?>
        <?php
        

         $sodu_lieu = mysqli_num_rows($conn->query("SELECT * FROM branch ") ) or die(mysql_error());
         $SoBaiTrenTrang = 10;
         $sotrang = floor($sodu_lieu/$SoBaiTrenTrang) +1;  
         //Xủ lí xóa công việc khi lick button xóa
          if(isset($_GET['id']))
            {
              $id = $_GET['id'];
                 $conn->query("Delete from branch where id=$id") or die(mysql_error()); 
                 echo '<div class="container" style="text-align: center">';
                 print " Đã Xóa Công Việc Được chọn ! .  <a href='javascript:history.go(-1)'>Nhấp vào đây để quay trở lại</a>";
                 echo '</div>';
                        exit;
            }
         if ( !isset($_GET['page']) )
         {
             $_GET['page'] = 1 ;
         }
        $BatDau=( $_GET['page']-1)*$SoBaiTrenTrang;
        $result =$conn->query("SELECT * FROM branch LIMIT $BatDau,$SoBaiTrenTrang") or die(mysql_error());
        

//        ?>      
        
        <div class="container" >
        <div class="row">
            <h2 class="text-center"> DANH SÁCH NGHỀ </h2>; 
        </div>
        <div class="row">
           <div class="text-center">
             <?php
            if($_GET['page']>1)
            {
                echo '<a href="?page='.($_GET['page']-1).'">Back&nbsp;&nbsp;</a>';
            }
            for ( $ViTri = 1; $ViTri<= $sotrang;  $ViTri++ )
            {
                if($ViTri== $_GET['page'])
                {
                    echo '<font style="color: #d62c1a">&nbsp;&nbsp;'.$ViTri.'&nbsp;&nbsp;</font>';
                }
                else 
                {
                    if($ViTri!=$sotrang)
                    {
                        echo '<a href="?page='.$ViTri.'">'.$ViTri.'</a>';
                    }                    
                }
            }
             if($_GET['page']<$sotrang)
            {
                echo '<a href="?page='.($_GET['page']+1).'">&nbsp;&nbsp;Next</a>';
            }
           
        ?>
        <form action="ShowListJobs.php" method="post">
        </div>
        </div>
        <div class="row">
        <table class="table table-striped">
        <thead>
            <tr style="background-color: infobackground">
                <td>STT</td>
                <th>Mã Nghề</th>
                <th>Tên nghề</th>
                <th>Mô Tã</th>
                <th class="text-center">Edit</th>
            </tr>
        </thead>
        <?php
        $STT=1;
        while ($row = mysqli_fetch_array($result)) {?>
        <tr>
            <td><?php echo $STT++?></td>
            <td><?php echo $row["id"]?></td>
            <td><?php        echo $row["name"];?></td>  
            <td><?php        echo $row["description"];?></td>
            <td class="text-center"><?php echo '<a style="text-decoration: none"  href="?id='.$row['id'].'"> <button type="button" name="btnXoa'.$STT.'" class="btn-sm">Xóa</a> ';?></button> <button type="button" name="btnSua<?php echo $STT?>" class="btn-sm">Sửa</button></td>
            </tr>        
        <?php }mysqli_close($conn)?>
        </table>
        </div>
        </div>      
        </form>
    </body>
    <?php
include "includes/footer.php";
?>
</html>
